package com.four.basicinfo.controller;

import com.four.basicinfo.code.ResponseData;
import com.four.basicinfo.dao.DocumentDao;
import com.four.basicinfo.entity.Document;
import com.four.basicinfo.entity.Information;
import com.four.basicinfo.entity.Parents;
import com.four.basicinfo.service.DocumentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/document")
@CrossOrigin
public class DocumentController extends BaseController {
    @Autowired
    DocumentDao documentDao;
    @Autowired
    DocumentService documentService;
    /**
     * 获取基本信息详细信息
     */
    @GetMapping("/selectById")
    public Document getInfo(Long id)
    {
        Document document=documentService.selectDocumentById(id);
        return document;
    }
    /**
     * 查询本人的出国列表
     */
    @GetMapping("/listBynum")
    public List<Document> list(Integer number){
        List<Document> list = documentDao.selectByNum(number);
        return list;
    }
    //修改
    @PutMapping("/update")
    public ResponseData<Boolean> update(Document document){
        Boolean b = documentService.updateDocument( document )>0;
        return returnBoolean( b );
    }

    //新增
    @PostMapping("/insert")
    public ResponseData<Boolean> insert(Document document){
        Boolean b = documentService.insertDocument( document )>0;
        return returnBoolean( b );
    }
    //删除
    @DeleteMapping("/delete")
    public ResponseData<Boolean> delete(Long id){
        Boolean b=documentService.deleteDocumentById(id)>0;
        return returnBoolean( b );
    }
}
